VERSION 5.00
Begin {AC0714F6-3D04-11D1-AE7D-00A0C90F26F4} Connect 
   ClientHeight    =   10335
   ClientLeft      =   1740
   ClientTop       =   1545
   ClientWidth     =   11235
   _ExtentX        =   19817
   _ExtentY        =   18230
   _Version        =   393216
   Description     =   "Imports a MapInfo or ESRI data file into MapPoint."
   DisplayName     =   "Spatial Data Import ..."
   AppName         =   "Microsoft MapPoint"
   AppVer          =   "Microsoft MapPoint 8.0"
   LoadName        =   "Startup"
   LoadBehavior    =   3
   RegLocation     =   "HKEY_CURRENT_USER\Software\Microsoft\MapPoint"
End
Attribute VB_Name = "Connect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'*************************************************************************
'  This source code is provided "as is" and as an unsupported sample of
'  a Microsoft Visual Basic application that incorporates the MapPoint 2002
'  object model and ActiveX control. It can only  be used in accordance with
'  the terms and conditions of the Microsoft MapPoint 2002 and
'  Microsoft Visual Basic End User License Agreements.
'*************************************************************************

Private WithEvents m_omApplication As MapPoint.Application
Attribute m_omApplication.VB_VarHelpID = -1

Public Sub ShowSpatialDataImport()
'**********************************************************************************
    ' Date: 3/13/2001
    ' Abstract: The initial function that gets called when the Addin is run.
    '           Shows the frmSpatialDataImport form.
    ' Assumptions:
    ' Notes:
'**********************************************************************************
    
    Dim lWindowHandle As Long
    Dim omMap As MapPoint.Map
    Dim bValidDataExists As Boolean
    
    On Error GoTo errorHandler
    
    'Get a reference to the active map
    Set omMap = m_omApplication.ActiveMap
    
    'Show the form
    frmSpatialDataImport.Display omMap, Me
    
    Exit Sub
errorHandler:
    MsgBox "Error in ShowSpatialDataImport" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Sub

Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
                                       ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
                                       ByVal AddInInst As Object, _
                                             custom() As Variant)
'**********************************************************************************
    ' Date: 3/13/2001
    ' Abstract: This method adds the Add-In to MapPoint.
    ' Assumptions:
    ' Notes:
'**********************************************************************************

    On Error GoTo errorHandler
    
    'Save a reference to the calling application object.
    Set m_omApplication = Application
    
    'Add the command to the list of available Addins.
    m_omApplication.AddCommand "Spatial Data Import...", _
                               "ShowSpatialDataImport", _
                               Me
    
    Exit Sub
errorHandler:
    MsgBox "Error in AddinInstance_OnConnection" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Sub

Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, _
                                                custom() As Variant)
'**********************************************************************************
    ' Date: 3/13/2001
    ' Abstract: This method removes the Add-In from MapPoint.
    ' Assumptions:
    ' Notes:
'**********************************************************************************
    
    On Error GoTo errorHandler
    
    'Release the form, if necessary.
    ReleaseForm
    
    'Make sure we have an Application object.
    If Not m_omApplication Is Nothing Then
        
        'Remove any existing commands related to this addin.
        m_omApplication.RemoveCommands Me
        
        'Release the reference to the Application object.
        Set m_omApplication = Nothing
        
    End If
    
    Exit Sub
errorHandler:
    MsgBox "Error in AddinInstance_OnDisconnection" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Sub

Private Sub m_omApplication_New()
'**********************************************************************************
    ' Date: 3/13/2001
    ' Abstract: If the user selects File--New, then we need to close the SpatialDataImport
    '           window so that the SpatialDataImport data isn't out-of-sync with the
    '           currently-loaded file.
    ' Assumptions:
    ' Notes:
'**********************************************************************************
    
    On Error GoTo errorHandler
    
    ReleaseForm
    
    Exit Sub
errorHandler:
    MsgBox "Error in m_omApplication_New" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Sub

Private Sub m_omApplication_Open()
'**********************************************************************************
    ' Date: 3/13/2001
    ' Abstract: If the user selects File--Open, then we need to close the SpatialDataImport
    '           window so that the SpatialDataImport data isn't out-of-sync with the
    '           currently-loaded file.
    ' Assumptions:
    ' Notes:
'**********************************************************************************
    
    On Error GoTo errorHandler
    
    ReleaseForm
    
    Exit Sub
errorHandler:
    MsgBox "Error in m_omApplication_Open" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Sub

Friend Sub ReleaseForm()
'**********************************************************************************
    ' Date: 3/13/2001
    ' Abstract: Unloads the current form, if there is one.
    ' Assumptions:
    ' Notes:
'**********************************************************************************
    
    On Error GoTo errorHandler
    
    If Not frmSpatialDataImport Is Nothing Then
        Unload frmSpatialDataImport
        Set frmSpatialDataImport = Nothing
    End If
    
    Exit Sub
errorHandler:
    MsgBox "Error in ReleaseForm" & vbCrLf _
         & "Error Number: " & Err.Number & vbCrLf _
         & "Error Description: " & Err.Description, vbExclamation, App.Title
End Sub


